package com.rcl.mvvmdemo.api

import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit

/**
 * 创建Retrofit已经提供API Server
 */
object RetrofitClient {
    val okhttpClient = OkHttpClient.Builder()
        .callTimeout(30, TimeUnit.SECONDS)
        .build()
    val retrofit = Retrofit.Builder()
        .baseUrl(ApiServer.BASE_URL)
        .addConverterFactory(GsonConverterFactory.create())
        .client(okhttpClient)
        .build()

    val apiServer = retrofit.create(ApiServer::class.java)

    val wanRetrofit = Retrofit.Builder()
        .baseUrl(ApiServer.BASE_URL_WAN_ANDROID)
        .addConverterFactory(GsonConverterFactory.create())
        .client(okhttpClient)
        .build()

    val wanApiServer = wanRetrofit.create(ApiServer::class.java)
}